﻿/* ==============================================================================
 * 功能描述：MonsterConfigProvider  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/18 22:21:06
 * ==============================================================================*/
using UnityEngine;
using System.Collections;

public class MonsterConfigProvider : BaseProvider<MonsterConfigProvider>
{
    private MonsterConfig monsterConfig;

    public MonsterConfig MonsterConfig
    {
        get
        {
            if (monsterConfig == null)
            {
                monsterConfig = LoadConfig<MonsterConfig>("/xml/monsterConfig.xml");
            }
            return monsterConfig;
        }
    }

    public MonsterConfigMonster[] GetAll()
    {
        return MonsterConfig.Items;
    }

    public MonsterConfigMonster GetMonsterById(int id)
    {
        MonsterConfigMonster monster = System.Array.Find<MonsterConfigMonster>(MonsterConfig.Items, (MonsterConfigMonster obj) =>
        {
            return int.Parse(obj.id) == id;
        });
        if (monster == null) Debug.Log("配置表中找不到该怪物，id：" + id);
        return monster;
    }
}